package cn.it.services.impl;

import cn.it.domain.Car;
import cn.it.mapper.CarMapper;
import cn.it.services.CarServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarServicesImpl implements CarServices {
    @Autowired
    private CarMapper carMapper;
    @Override
    public Car searchCarById(Integer id) {
        if(id == null){
            System.out.println("请输入ID");
            return null;
        }else {
            System.out.println("查询数据库");
            Car car = carMapper.searchCarById(id);
            return car;
        }
    }

    @Override
    public List<Car> selectAll() {
        List<Car> cars = carMapper.selectAll();
        if (cars.isEmpty()){
            System.out.println("没有车");
            return null;
        }
        return cars;
    }
}
